#include <stdexcept>

#include "model/island.h"
#include "model/bridge.h"

Island::Island(int maxBridges, std::pair<unsigned int, unsigned int> position)
: position(position), connectedBridges() {
	if (maxBridges > 0 && maxBridges <= 8)
		this->maxBridges = maxBridges;
	else
		throw std::invalid_argument("maxBridges must be between 1 and 8");
}

void Island::connectBridge(Bridge* bridge) {
	this->connectedBridges.push_back(bridge);
}

int Island::getNumberOfConnectedBridges() {
	return this->connectedBridges.size();
}

int Island::getMaxNumberOfBridges() {
	return this->maxBridges;
}

int Island::getRemainingNumberOfBridges() {
	return this->getMaxNumberOfBridges() - this->getNumberOfConnectedBridges();
}

std::pair<unsigned int, unsigned int> Island::getPosition() {
	return this->position;
}
